<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible;
}

.ui-widget {
	font-size: 9px !important;
}

.centro {
	top: 50%
}

.tabela {
	width: 800px;
}

.semBorda tr,.semBorda td {
	border: none !important;
}

.size {
	width: 800px;
	position: absolute;
	left: 15%;
	top: 10%;
}
</style>

	<script type="text/javascript">
		PrimeFaces.locales['pt'] = {
			closeText : 'Fechar',
			prevText : 'Anterior',
			nextText : 'Próximo',
			currentText : 'Começo',
			monthNames : [ 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio',
					'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro',
					'Novembro', 'Dezembro' ],
			monthNamesShort : [ 'Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun',
					'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez' ],
			dayNames : [ 'Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta',
					'Sexta', 'Sábado' ],
			dayNamesShort : [ 'Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb' ],
			dayNamesMin : [ 'D', 'S', 'T', 'Q', 'Q', 'S', 'S' ],
			weekHeader : 'Semana',
			firstDay : 0,
			isRTL : false,
			showMonthAfterYear : false,
			yearSuffix : '',
			timeOnlyTitle : 'Só Horas',
			timeText : 'Tempo',
			hourText : 'Hora',
			minuteText : 'Minuto',
			secondText : 'Segundo',
			ampm : false,
			month : 'Mês',
			week : 'Semana',
			day : 'Dia',
			allDayText : 'Todo o Dia'
		};
	</script>

	<title>Suporte T.I</title>
</h:head>

<h:body>

	<ui:decorate template="/templateBase.xhtml">
		<ui:define name="center">
			<p:growl id="growl" life="3000" autoUpdate="false" />
			<h:form id="formSuporte" acceptcharset="ISO-8859-1" lang="pt">
				<br />
				<br />
				<br />
				<p:panel styleClass="size"
					header="Suporte - Tecnologia da Informação"
					footer="Integração - Portal de Serviços e Comunicação"
					id="panelAgendamentos">
					<br />
					<p:tabView id="tabView">

						<p:tab title="Novo Chamado" id="tabChamado">
							<br />
							<h:panelGrid>

								<h:outputText value="Categoria" />
								<p:selectOneMenu required="true"
									value="#{ordemDeServicoBacking.codCategoriaSelecionada}"
									requiredMessage="Informe a categoria">
									<f:selectItem itemDisabled="true" itemLabel="Selecione" />
									<f:selectItems value="#{ordemDeServicoBacking.listaCategoria}"
										var="c" itemLabel="#{c.descricao}" itemValue="#{c.id}" />
								</p:selectOneMenu>

								<h:outputText value="Motivo" />
								<p:selectOneMenu required="true"
									value="#{ordemDeServicoBacking.codMotivoSelecionado}"
									requiredMessage="Informe o motivo">
									<f:selectItem itemDisabled="true" itemLabel="Selecione" />
									<f:selectItems value="#{ordemDeServicoBacking.listaMotivo}"
										var="m" itemLabel="#{m.descricao}" itemValue="#{m.id}" />
								</p:selectOneMenu>

								<h:outputText value="Equipamento" />
								<p:selectOneMenu
									value="#{ordemDeServicoBacking.codEqSelecionado}">
									<f:selectItem itemDisabled="true" itemLabel="Selecione" />
									<f:selectItems
										value="#{ordemDeServicoBacking.listaEquipamento}" var="e"
										itemLabel="#{e.descricao}" itemValue="#{e.id}" />
								</p:selectOneMenu>

								<h:outputText value="Assunto:" />
								<p:inputText size="70" required="true"
									value="#{ordemDeServicoBacking.odSalvar.assunto}"
									requiredMessage="Informe o assunto!" />
								<h:outputText value="Justificativa" />
								<p:inputTextarea cols="100" rows="5" autoResize="true"
									value="#{ordemDeServicoBacking.odSalvar.justificativa}" />

								<p:fileUpload
									fileUploadListener="#{ordemDeServicoBacking.upload}"
									sizeLimit="100000" label="Selecionar" update="tblArquivo"
									invalidSizeMessage="Tamanho inválido"
									invalidFileMessage="Arquivo inválido" showButtons="false" />
								<br />
								<p:graphicImage url="../images/anexo.jpg" width="20" height="15" />
								<b>Anexos</b>
								<p:dataList value="#{ordemDeServicoBacking.listaArquivoAnexo}" var="a"
									itemtype="circle" id="tblArquivo">
									<p:graphicImage url="../images/clips.jpg" width="20"
										height="15" />
								</p:dataList>
								<br />


							</h:panelGrid>
							<br />
							<p:separator />
							<br />
							<div align="center">
								<h:panelGrid columns="2">
									<p:commandButton value="Gravar"
										actionListener="#{ordemDeServicoBacking.salvarChamado}"
										ajax="false" />
									<p:commandButton value="Cancelar" />
								</h:panelGrid>
							</div>
						</p:tab>

						<p:tab title="Meus Chamados">
							<div align="right">
								<p:commandButton value="Atualiazar" icon="ui-icon-refresh"
									action="#{ordemDeServicoBacking.criaListaTodosChamados}"
									update="t_meusChamados" process="@this" />
								<br /> <br />
							</div>
							<p:dataTable value="#{ordemDeServicoBacking.listaTodosChamados}"
								var="b" id="t_meusChamados" rows="6" paginator="true"
								emptyMessage="Não consta nenhum chamado na base de dados!">

								<p:column headerText="ID">
									<h:outputText value="#{b.ordemServico.id}" />
								</p:column>

								<p:column headerText="Data">
									<h:outputText value="#{b.ordemServico.dataEntrada}">
										<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
									</h:outputText>
								</p:column>

								<p:column headerText="Atendente">
									<h:outputText value="#{b.atendente.nome}" />
								</p:column>

								<p:column headerText="Assunto">
									<div align="center">
										<h:outputText value="#{b.ordemServico.assunto}" />
									</div>
								</p:column>

								<p:column headerText="Categoria">
									<div align="center">
										<h:outputText value="#{b.ordemServico.categoria.descricao}" />
									</div>
								</p:column>

								<p:column headerText="Motivo">
									<div align="center">
										<h:outputText value="#{b.ordemServico.motivo.descricao}" />
									</div>
								</p:column>

								<p:column headerText="Status">
									<div align="center">
										<h:outputText value="#{b.ordemServico.status}" />
									</div>
								</p:column>

								<p:column headerText="Detalhes">
									<div align="center">

										<p:commandButton icon="ui-icon-search"
											update=":formAtendimento"
											action="#{ordemDeServicoBacking.selecionaOrdemServico(b)}"
											immediate="true" onclick="dlgAtendimento.show()" />

									</div>
								</p:column>

							</p:dataTable>

						</p:tab>

					</p:tabView>
				</p:panel>
			</h:form>

			<p:dialog widgetVar="dlgAtendimento" showEffect="clip"
				hideEffect="clip" header="Atendimento" width="650" height="400">
				<h:form id="formAtendimento">

					<h:panelGrid>

						<h:outputText value="Categoria" />
						<p:inputText size="50" readonly="true"
							value="#{ordemDeServicoBacking.ordemSelecionada.ordemServico.categoria.descricao}" />

						<h:outputText value="Motivo" />
						<p:inputText size="50" readonly="true"
							value="#{ordemDeServicoBacking.ordemSelecionada.ordemServico.motivo.descricao}" />

						<h:outputText value="Equipamento" />
						<p:inputText size="50" readonly="true"
							value="#{ordemDeServicoBacking.ordemSelecionada.ordemServico.equipamento.descricao}" />

						<h:outputText value="Assunto:" />
						<p:inputText size="70" readonly="true"
							value="#{ordemDeServicoBacking.ordemSelecionada.ordemServico.assunto}" />

						<h:outputText value="Justificativa" />
					</h:panelGrid>
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Finalizar" ajax="false" process="@this"
								action="#{ordemDeServicoBacking.finalizarAtendimento(ordemDeServicoBacking.ordemSelecionada.id)}" />

							<p:commandButton value="Cancelar" onclick="dlgAtender.hide()" />
						</h:panelGrid>
					</div>
					<br />
					<p:separator />
					<br />

					<br />
					<p:separator />
					<br />
					<h:form prependId="false">
						<p:accordionPanel multiple="true">
							<p:tab title="Comentários">


								<h:outputLabel value="Comentário: " />
								<div align="center">
									<p:inputTextarea autoResize="true" cols="100" rows="4"
										value="#{ordemDeServicoBacking.comentarioOS.comentario}" />
									<br /> <br />
									<p:commandButton
										action="#{ordemDeServicoBacking.inserirComentariosOS(ordemDeServicoBacking.ordemSelecionada.ordemServico.id)}"
										value="Salvar" icon="ui-icon-check" update=":formAtendimento"
										onsuccess="dlgAtendimento.hide()" />
								</div>
								<br />
								<p:separator />
								<br />

								<div align="center">
									<p:panel
										header="#{ordemDeServicoBacking.listaComentarios.size()} - Cometário(s)"
										style="margin-left: 0">
										<p:dataTable value="#{ordemDeServicoBacking.listaComentarios}"
											var="c"
											emptyMessage="Não consta comentários na base de dados">

											<p:column>
												<p:inputTextarea value="#{c.comentario}" readonly="true"
													autoResize="true" style="background-color: yellow"
													cols="93" />
												<div align="right">
													<h:outputLabel value="#{c.funcionario.nome} - " />
													<h:outputLabel value="#{c.dataComentario}">
														<f:convertDateTime
															pattern="EEEE,dd 'de' MMMM 'de' yyyy - HH:mm:ss"
															timeZone="GMT-3" locale="pt_BR" />
													</h:outputLabel>
												</div>
												<br />
											</p:column>

										</p:dataTable>
									</p:panel>
								</div>
							</p:tab>
						</p:accordionPanel>
					</h:form>
				</h:form>
			</p:dialog>


		</ui:define>
	</ui:decorate>
</h:body>
</html>